package com.roads.web.controller.system;

import java.util.List;

import com.roads.common.constant.Constants;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.roads.common.annotation.Log;
import com.roads.common.core.controller.BaseController;
import com.roads.common.core.domain.AjaxResult;
import com.roads.common.enums.BusinessType;
import com.roads.system.domain.SysMessage;
import com.roads.system.service.ISysMessageService;
import com.roads.common.utils.poi.ExcelUtils;
import com.roads.common.core.page.TableDataInfo;

/**
 * 消息Controller
 * 
 * @author nhp
 * @date 2022-03-22
 */
@RestController
@RequestMapping("/system/message")
public class SysMessageController extends BaseController {

    @Autowired
    private ISysMessageService service;

    /**
     * 查询消息数量
     *
     * @return 数量
     */
    @GetMapping("/getMessageCount")
    public AjaxResult getMessageCount() {
        SysMessage search = new SysMessage();
        search.setMessageUser(getUsername());
        search.setMessageStatus(Constants.MESSAGE_STATUS_UNTREATED);
        int messageCount = service.getMessageCount(search);
        return success().put("messageCount", messageCount);
    }

    /**
     * 查询列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysMessage model) {
        model.setMessageStatus(Constants.MESSAGE_STATUS_UNTREATED);
        model.setMessageUser(getUsername());
        startPage();
        List<SysMessage> list = service.selectModelList(model);
        return getDataTable(list);
    }

}
